/**
 * [dateDiff 算时间差]
 * @param  {[type=Number]} hisTime [历史时间戳，必传]
 * @param  {[type=Number]} nowTime [当前时间戳，不传将获取当前时间戳]
 * @return {[string]}         [string]
 */
export function dateDiff(hisTime: any, nowTime: any) {
    let now = nowTime ? nowTime : new Date().getTime(),
        difft = now - Date.parse(hisTime),
        result = '',
        minute = 1000 * 60,
        hour = minute * 60,
        day = hour * 24,
        month = day * 30,
        year = month * 12,

        _year = Math.round(difft / year),
        _month = Math.round(difft / month),
        // _week = Math.round(difft / (7 * day)),
        _day = Math.round(difft / day),
        _hour = Math.round(difft / hour),
        _min = Math.round(difft / minute);

    console.log('difft',difft)
    if (_year >= 1) result = (_year) + " year ago";
    else if (_month >= 1) result = (_month) + " months ago";
    // else if (_week >= 1) result = (_week) + "周前";
    else if (_day >= 1) result = (_day) + " days ago";
    else if (_hour >= 1) result = (_hour) + " hours  gao";
    else if (_min >= 1) result = (_min) + " minutes ago";
    else result = "just now";
    return result;
}


